package org.mycompany.resource;

import java.net.URL;

import com.sun.faces.facelets.impl.DefaultResourceResolver;

public class CustomResourceResolver extends DefaultResourceResolver {

	private static final String resourcePrefix = "/org/mycompany/";

	public CustomResourceResolver() {
		super();
	}

	@Override
	public URL resolveUrl(String resource) {
		URL resourceUrl = super.resolveUrl(resource);
		if (resourceUrl == null) {
			if (resource.startsWith("/")) {
				resource = resource.substring(1);
			}
			try {
				resourceUrl = Thread.currentThread().getContextClassLoader()
						.getResource(resourcePrefix + resource);
			} catch (final Exception e) {
				e.printStackTrace();
			}
			
		}
		return resourceUrl;
	}

}
